{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "# wrong test\n",
    "# debug\n",
    "from matrix import polygon2mask, polygon2mask2\n",
    "import numpy as np\n",
    "import cv2\n",
    "from matplotlib import pyplot as plt\n",
    "\n",
    "\n",
    "polygon = np.array([430.13250732421875, 268.0, 430.13250732421875, 268.0, 429.14251708984375, 261.8999938964844, 431.9849853515625, 258.2699890136719, 440.39251708984375, 259.760009765625, 444.72003173828125, 259.5899963378906, 449.66998291015625, 260.5799865722656, 454.2449951171875, 261.4100036621094, 456.72003173828125, 262.55999755859375, 458.20501708984375, 264.70001220703125, 459.31500244140625, 268.0, 460.67999267578125, 270.1499938964844, 462.53253173828125, 271.6300048828125, 464.760009765625, 272.95001220703125, 466.739990234375, 274.760009765625, 467.7225036621094, 276.0799865722656, 468.96002197265625, 275.260009765625, 469.2074890136719, 275.5899963378906, 469.45501708984375, 277.3999938964844, 470.3249816894531, 279.7099914550781, 470.572509765625, 282.67999267578125, 470.6925048828125, 285.80999755859375, 470.6925048828125, 285.9800109863281, 470.6925048828125, 288.94000244140625, 470.572509765625, 289.92999267578125, 468.59246826171875, 290.260009765625, 466.11749267578125, 289.1099853515625, 464.2650146484375, 287.95001220703125, 462.6524963378906, 285.1499938964844, 461.9100036621094, 283.5, 458.6999816894531, 281.5199890136719, 456.72003173828125, 281.8500061035156, 454.739990234375, 283.010009765625, 454.6199951171875, 283.1700134277344, 453.50250244140625, 284.3299865722656, 453.135009765625, 287.1300048828125, 453.2550048828125, 287.4599914550781, 453.38250732421875, 290.1000061035156, 453.38250732421875, 290.42999267578125, 453.2550048828125, 292.239990234375, 451.52252197265625, 292.739990234375, 449.1750183105469, 291.0899963378906, 448.3125, 288.94000244140625, 448.3125, 285.9800109863281, 448.06500244140625, 283.010009765625, 446.947509765625, 283.010009765625, 445.71002197265625, 283.8299865722656, 444.23248291015625, 284.1600036621094, 442.0050048828125, 284.0, 437.677490234375, 282.17999267578125, 436.55999755859375, 279.2200012207031, 437.1824951171875, 275.0899963378906, 433.34246826171875, 269.32000732421875, 431.12249755859375, 268.0], dtype=np.float32)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[<matplotlib.lines.Line2D at 0x128e0c550>]"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAD4CAYAAAAXUaZHAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAgAElEQVR4nO3dd3xVVbr/8c+TTiqkk07vVURGBPtPUWfUcRz72BkdddTrnaJ32p0Z7zTHKeqoKLbRsYKOBceKqKgIoTchCYQkJJBCes7JKev3x9lAQCCB5GSf8rxfr7w42Xufkyeb5HtW1l57LTHGoJRSKrRE2F2AUkqpvqfhrpRSIUjDXSmlQpCGu1JKhSANd6WUCkFRdhcAkJ6eboqKiuwuQymlgkpxcXGdMSbjUPsCItyLiopYsWKF3WUopVRQEZHyw+3TbhmllApBGu5KKRWCNNyVUioEabgrpVQI0nBXSqkQpOGulFIhSMNdKaVCUECMc1cqFOxs7GDRumqGpCcwpWAQqQkxdpekwpiGu1K91Oxw8fBHpTzx6Tacbu++7UPTE5haOIjjrI/hGYlERIiNlapwouGu1DHqdHv517Jy/v5hCQ1tnVwwOYdbTxtBfauT4h17WFm+hw837+aV4koAkuKimFowiKkFvrCfXDCQxFj9FVT+oT9ZSh0lYwxvr6/hj//ZzPb6dk4clsY954xhfG4KAMMzEzlhaNq+Y7fXt1Ncvoficl/g//WDLRgDEQKjspO5YHIO3z95mJ3fkgpBEgjL7E2bNs3o3DIqGBSXN3DvW5tYuaORkVmJ3D1nDKeMykCk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zk6xPbWLo/1HFnnCBhs/Sv4/tT+vfX5ucDb1vYZwJd2123zefo9cF2X7cv1PH399w24CXj6oGP8eo6ijvVNIUAJ8LR14UKANfgu+ADMB/5ptVIb8IWXOpCeo/2eE5EMfD9Hq/H9cgIsAs4BSoB24Fp7ygsYv8d3ru4EWoEbrO16ng50Kb5z1ZVfz5FOP6CUUiEomPvclVJKHYaGu1JKhSANd6WUCkEa7kopFYI03JVSKgRpuCulVAjScFdKqRD0/wEHJngX2Fu+5gAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "polygon_show = polygon.reshape(-1,2)\n",
    "plt.plot(polygon_show[:,0], polygon_show[:,1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "points_num:in 54\n",
      "points_num:out 52\n",
      "y_dict: []\n",
      "268: 430.1325\n",
      "268: 459.315\n",
      "268: 431.1225\n",
      "y_dict: [431.1225, 459.315]\n"
     ]
    }
   ],
   "source": [
    "mask = polygon2mask([480,480], polygon)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "mask = mask*255\n",
    "cv2.imwrite(\"mask1.jpg\", mask)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],\n",
       "       [0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],\n",
       "       [0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],\n",
       "       [0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],\n",
       "       [0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],\n",
       "       [0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],\n",
       "       [0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],\n",
       "       [0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],\n",
       "       [0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],\n",
       "       [0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]], dtype=float32)"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "mask[245:255, 180:190]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "(mask==0).all()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "mask[0][0]=1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
